Skip to content

[filters] type meta.value as string or object#253537

Merged
nreese merged 12 commits intoelastic:mainfrom
nreese:value_as_object
Feb 20, 2026
Merged

[filters] type meta.value as string or object#253537
nreese merged 12 commits intoelastic:mainfrom
nreese:value_as_object

Conversation

@nreese
Copy link
Copy Markdown
Contributor

@nreese nreese commented Feb 17, 2026

Fixes #253480

storedFilterMetaSchema.value schema is too restrictive and needs to be broadened. This PR broadens storedFilterMetaSchema.value to any since storedFilterMetaSchema.value is a subset of FilterMetaParams and to prevent future issues like this.

PR also updates FilterMeta.value type to more accurately reflect usage.

mapPhrases sets value to PhraseFilterValue[]

export const mapPhrases = (filter: Filter) => {
  if (!isPhrasesFilter(filter)) {
    throw filter;
  }

  const { type, key, params } = filter.meta;

  return {
    type,
    key,
    value: params,
    params,
  };
};

mapRange sets value to RangeFilterParams

function getParams(filter: RangeFilter) {
  const isScriptedRange = isScriptedRangeFilter(filter);
  const key: string = (isScriptedRange ? filter.meta.field : getFirstRangeKey(filter)) || '';
  const params: any = isScriptedRange
    ? get(filter.query, 'script.script.params')
    : getRangeByKey(filter, key);

  return { type: FILTERS.RANGE, key, value: params, params };
}

export const mapRange = (filter: Filter) => {
  if (!isMapRangeFilter(filter)) {
    throw filter;
  }

  return getParams(filter);
};

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 17, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 18, 2026

@elasticmachine merge upstream

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 18, 2026

/ci

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 18, 2026

@elasticmachine merge upstream

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 18, 2026

/ci

@nreese nreese marked this pull request as ready for review February 18, 2026 13:20
@nreese nreese requested review from a team as code owners February 18, 2026 13:20
@nreese nreese added release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// backport:version Backport to applied version labels v9.4.0 v9.3.1 labels Feb 18, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@lukasolson lukasolson assigned lukasolson and unassigned lukasolson Feb 18, 2026
@lukasolson lukasolson self-requested a review February 18, 2026 15:32
Copy link
Copy Markdown
Contributor

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks for reviewing and fixing this. code review and tested saving filters with maps app

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 20, 2026

@elasticmachine merge upstream

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 20, 2026

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 439.1KB 439.1KB +8.0B

History

@nreese nreese merged commit 64510c0 into elastic:main Feb 20, 2026
16 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.3

https://github.com/elastic/kibana/actions/runs/22239325345

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Feb 20, 2026
Fixes elastic#253480

`storedFilterMetaSchema.value` schema is too restrictive and needs to be
broadened. This PR broadens `storedFilterMetaSchema.value` to any since
`storedFilterMetaSchema.value` is a subset of `FilterMetaParams` and to
prevent future issues like this.

PR also updates `FilterMeta.value` type to more accurately reflect
usage.

[mapPhrases](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_phrases.ts#L32)
sets value to `PhraseFilterValue[]`
```
export const mapPhrases = (filter: Filter) => {
  if (!isPhrasesFilter(filter)) {
    throw filter;
  }

  const { type, key, params } = filter.meta;

  return {
    type,
    key,
    value: params,
    params,
  };
};
```

[mapRange](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_range.ts#L54)
sets value to `RangeFilterParams`

```
function getParams(filter: RangeFilter) {
  const isScriptedRange = isScriptedRangeFilter(filter);
  const key: string = (isScriptedRange ? filter.meta.field : getFirstRangeKey(filter)) || '';
  const params: any = isScriptedRange
    ? get(filter.query, 'script.script.params')
    : getRangeByKey(filter, key);

  return { type: FILTERS.RANGE, key, value: params, params };
}

export const mapRange = (filter: Filter) => {
  if (!isMapRangeFilter(filter)) {
    throw filter;
  }

  return getParams(filter);
};
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 64510c0)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 20, 2026
# Backport

This will backport the following commits from `main` to `9.3`:
- [[filters] type meta.value as string or object
(#253537)](#253537)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2026-02-20T20:07:08Z","message":"[filters]
type meta.value as string or object (#253537)\n\nFixes
https://github.com/elastic/kibana/issues/253480\n\n`storedFilterMetaSchema.value`
schema is too restrictive and needs to be\nbroadened. This PR broadens
`storedFilterMetaSchema.value` to any
since\n`storedFilterMetaSchema.value` is a subset of `FilterMetaParams`
and to\nprevent future issues like this.\n\nPR also updates
`FilterMeta.value` type to more accurately
reflect\nusage.\n\n\n[mapPhrases](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_phrases.ts#L32)\nsets
value to `PhraseFilterValue[]`\n```\nexport const mapPhrases = (filter:
Filter) => {\n if (!isPhrasesFilter(filter)) {\n throw filter;\n }\n\n
const { type, key, params } = filter.meta;\n\n return {\n type,\n key,\n
value: params,\n params,\n
};\n};\n```\n\n\n[mapRange](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_range.ts#L54)\nsets
value to `RangeFilterParams`\n\n```\nfunction getParams(filter:
RangeFilter) {\n const isScriptedRange =
isScriptedRangeFilter(filter);\n const key: string = (isScriptedRange ?
filter.meta.field : getFirstRangeKey(filter)) || '';\n const params: any
= isScriptedRange\n ? get(filter.query, 'script.script.params')\n :
getRangeByKey(filter, key);\n\n return { type: FILTERS.RANGE, key,
value: params, params };\n}\n\nexport const mapRange = (filter: Filter)
=> {\n if (!isMapRangeFilter(filter)) {\n throw filter;\n }\n\n return
getParams(filter);\n};\n```\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"64510c0529ccf2549e36b932a561ec335a1415e7","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","backport:version","v9.4.0","v9.3.1"],"title":"[filters]
type meta.value as string or
object","number":253537,"url":"https://github.com/elastic/kibana/pull/253537","mergeCommit":{"message":"[filters]
type meta.value as string or object (#253537)\n\nFixes
https://github.com/elastic/kibana/issues/253480\n\n`storedFilterMetaSchema.value`
schema is too restrictive and needs to be\nbroadened. This PR broadens
`storedFilterMetaSchema.value` to any
since\n`storedFilterMetaSchema.value` is a subset of `FilterMetaParams`
and to\nprevent future issues like this.\n\nPR also updates
`FilterMeta.value` type to more accurately
reflect\nusage.\n\n\n[mapPhrases](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_phrases.ts#L32)\nsets
value to `PhraseFilterValue[]`\n```\nexport const mapPhrases = (filter:
Filter) => {\n if (!isPhrasesFilter(filter)) {\n throw filter;\n }\n\n
const { type, key, params } = filter.meta;\n\n return {\n type,\n key,\n
value: params,\n params,\n
};\n};\n```\n\n\n[mapRange](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_range.ts#L54)\nsets
value to `RangeFilterParams`\n\n```\nfunction getParams(filter:
RangeFilter) {\n const isScriptedRange =
isScriptedRangeFilter(filter);\n const key: string = (isScriptedRange ?
filter.meta.field : getFirstRangeKey(filter)) || '';\n const params: any
= isScriptedRange\n ? get(filter.query, 'script.script.params')\n :
getRangeByKey(filter, key);\n\n return { type: FILTERS.RANGE, key,
value: params, params };\n}\n\nexport const mapRange = (filter: Filter)
=> {\n if (!isMapRangeFilter(filter)) {\n throw filter;\n }\n\n return
getParams(filter);\n};\n```\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"64510c0529ccf2549e36b932a561ec335a1415e7"}},"sourceBranch":"main","suggestedTargetBranches":["9.3"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/253537","number":253537,"mergeCommit":{"message":"[filters]
type meta.value as string or object (#253537)\n\nFixes
https://github.com/elastic/kibana/issues/253480\n\n`storedFilterMetaSchema.value`
schema is too restrictive and needs to be\nbroadened. This PR broadens
`storedFilterMetaSchema.value` to any
since\n`storedFilterMetaSchema.value` is a subset of `FilterMetaParams`
and to\nprevent future issues like this.\n\nPR also updates
`FilterMeta.value` type to more accurately
reflect\nusage.\n\n\n[mapPhrases](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_phrases.ts#L32)\nsets
value to `PhraseFilterValue[]`\n```\nexport const mapPhrases = (filter:
Filter) => {\n if (!isPhrasesFilter(filter)) {\n throw filter;\n }\n\n
const { type, key, params } = filter.meta;\n\n return {\n type,\n key,\n
value: params,\n params,\n
};\n};\n```\n\n\n[mapRange](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/data/public/query/filter_manager/lib/mappers/map_range.ts#L54)\nsets
value to `RangeFilterParams`\n\n```\nfunction getParams(filter:
RangeFilter) {\n const isScriptedRange =
isScriptedRangeFilter(filter);\n const key: string = (isScriptedRange ?
filter.meta.field : getFirstRangeKey(filter)) || '';\n const params: any
= isScriptedRange\n ? get(filter.query, 'script.script.params')\n :
getRangeByKey(filter, key);\n\n return { type: FILTERS.RANGE, key,
value: params, params };\n}\n\nexport const mapRange = (filter: Filter)
=> {\n if (!isMapRangeFilter(filter)) {\n throw filter;\n }\n\n return
getParams(filter);\n};\n```\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"64510c0529ccf2549e36b932a561ec335a1415e7"}},{"branch":"9.3","label":"v9.3.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v9.3.1 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[maps] unable to save map with filter

7 participants